package com.cn.lyl.servlet.leaving;

import com.alibaba.fastjson.JSONObject;
import com.cn.lyl.model.LeavingModel;
import com.cn.lyl.service.LeavingService;
import com.cn.lyl.service.impl.LeavingServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/leaving/findInfo")
public class FindInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        int id = Integer.parseInt(req.getParameter("id"));
        LeavingService leavingService = new LeavingServiceImpl();
        LeavingModel info = leavingService.findInfo(id);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("data",info);
        resp.getWriter().print(jsonObject);
    }
}
